package com.fhao.java_gobang.service;

import com.fhao.java_gobang.mapper.UserMapper;
import com.fhao.java_gobang.model.User;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;
    public User selectByName(String username) {
        return userMapper.selectByName(username);
    }

    public Boolean insert(User user) {
        try {
            Integer result = userMapper.insert(user);
            if(result == 1) {
                return true;
            }
        }catch (Exception e) {
            log.error("添加图书失败,e: ",e);
        }
        return false;
    }

    public User selectById(Integer id) {
        return userMapper.selectById(id);
    }
}
